﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace King.Box.Utils.Global
{
    public class GlobalEnum
    {
        public static string GetEnumDescription<T>(int val)
        {
            try
            {
                var type = typeof(T);

                if (!Enum.IsDefined(type, val))
                    return string.Empty;

                FieldInfo fi = type.GetField(Enum.GetName(type, val));
                DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
                return (attributes.Length > 0) ? attributes[0].Description : Enum.GetName(type, val);
            }
            catch
            {
                return string.Empty;
            }
        }

        #region 系统用户
        public enum SysUserStatus : int
        {
            [Description("正常")]
            Normal = 0,
            [Description("冻结")]
            Freeze = 1,
        }
        #endregion

        #region 系统角色
        public enum SysPermissionReferType
        {
            [Description("菜单")]
            Menu = 10,
            [Description("操作")]
            Operation = 20,
        }
        #endregion

        #region 系统菜单
        public enum MenuLevel
        {
            [Description("一级菜单")]
            Level1 = 1,
            [Description("二级菜单")]
            Level2 = 2,
            [Description("三级菜单")]
            Level3 = 3,
        }
        #endregion

        #region YN
        public enum YN : int
        {
            [Description("否")]
            No = 0,
            [Description("是")]
            Yes = 1,

        }
        #endregion

        #region HttpMethod
        public enum HttpMethod : int
        {
            GET = 10,
            POST = 20,
            PUT = 30,
            PATCH = 40,
            DELETE = 50
        }
        #endregion
    }
}
